package org.ichow.core
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.EventDispatcher;
	
	/**
	 * ...
	 * @author M.ichow
	 */
	public class NotiCore extends EventDispatcher
	{
		protected var _container : DisplayObjectContainer;
		protected var _noti : DisplayObject;
		protected var skin : DisplayObjectContainer;
		
		public function NotiCore()
		{
		}
		
		protected function init() : void
		{
			//get skin container
			skin = _noti as DisplayObjectContainer;
			if ( !skin )
				return;
		}
		
		protected function addListeners() : void
		{
		}
		
		protected function removeListeners() : void
		{
		}
		
		public function activate() : void
		{
			addListeners();
			_container.addChild( _noti );
		}
		
		public function cancel( isHide : Boolean = true ) : void
		{
			removeListeners();
			if ( _container.contains( _noti ) && isHide )
				_container.removeChild( _noti );
		}
		
		public function reset() : void
		{
		}
		
		public function update( o : Object = null ) : void
		{
			for ( var i : Object in o )
			{
				if ( this.hasOwnProperty( i ) )
					this[ i ] = o[ i ];
				else if ( _noti.hasOwnProperty( i ) )
					_noti[ i ] = o[ i ];
			}
		}
		
		public function get noti() : DisplayObject
		{
			return _noti;
		}
		
		public function bind( noti : DisplayObject , container : DisplayObjectContainer ) : void
		{
			_container = container;
			_noti = noti;
			init();
		}
	
	}

}